package com.bcx.crm.spring_boot.conditional;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Created by ys on 2018/5/12.
 * 1.执行配置文件ConditionConfig.java,根据@Conditional注解的类的返回值为true生成对应的javaBean
 * 2.若ConditionConfig.java的@Conditional返回值全部是false时,此处报错:no-qualifying
 *   意思是:ListService接口的所有实现类中没有一个生成了Bean
 */
public class Main {
    public static void main(String[] args) {
        //1.
        AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext(ConditionConfig.class);
        ListService listService = configApplicationContext.getBean(ListService.class);//2.
        System.out.println(
                "当前操作系统是:"+
                configApplicationContext.getEnvironment().getProperty("os.name")+
                        "。 系统下的列表命令为:"+
                        listService.showListCmd()
        );
    }
}
